package com.easemob.util;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class ZipUtils
{
  private static final int BUFF_SIZE = 1048576;

  public static void zip(File paramFile1, File paramFile2)
    throws IOException
  {
    if (!paramFile1.exists())
      return;
    ZipOutputStream localZipOutputStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(paramFile2), 1048576));
    zipFiles(paramFile1, localZipOutputStream, "");
    localZipOutputStream.flush();
    localZipOutputStream.close();
  }

  static void zipFiles(File paramFile, ZipOutputStream paramZipOutputStream, String paramString)
    throws IOException
  {
    if (!paramFile.exists())
      return;
    if (paramFile.isDirectory())
    {
      File[] arrayOfFile1 = paramFile.listFiles();
      if (arrayOfFile1 != null)
        for (File localFile : arrayOfFile1)
          zipFiles(localFile, paramZipOutputStream, paramString + "\\" + localFile.getName());
    }
    else
    {
      zipFile(paramFile, paramZipOutputStream, paramString);
    }
  }

  static void zipFile(File paramFile, ZipOutputStream paramZipOutputStream, String paramString)
    throws IOException
  {
    byte[] arrayOfByte = new byte[1048576];
    BufferedInputStream localBufferedInputStream = new BufferedInputStream(new FileInputStream(paramFile), 1048576);
    String str = null;
    if ("".equals(paramString))
      str = paramFile.getName();
    else
      str = paramString + "\\" + paramFile.getName();
    paramZipOutputStream.putNextEntry(new ZipEntry(paramString));
    int i;
    while ((i = localBufferedInputStream.read(arrayOfByte)) != -1)
      paramZipOutputStream.write(arrayOfByte, 0, i);
    localBufferedInputStream.close();
    paramZipOutputStream.flush();
    paramZipOutputStream.closeEntry();
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     com.easemob.util.ZipUtils
 * JD-Core Version:    0.6.1
 */